/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ow.framework.data.po;

import com.ow.framework.common.Constant;



/**
 *
 * @author Administrator
 */
public class PaginatedData extends AbstractBean{	

    /**总记录数*/
    private int recordCount = 0;
	/**当前页*/
	private int currentPage = 0;
	/**当前页*/
	private int pageSize = 10;
	/**分页开始值*/
	private int start = 0;
	/**偏移量*/
	private int offset = 0;
	
	public PaginatedData()
	{
		
	}
	
	public PaginatedData(String datasourceName,int pageSize,int currentPage)
	{
		if (currentPage == 0)
			currentPage = 1;
		datasourceName = datasourceName == null ? "" : datasourceName;
		int idx = datasourceName.indexOf("_");
		if (idx > -1){
			String dsname = datasourceName.substring(0,idx);
			if (dsname.equals(Constant.DATASOURCE_MYSQL)){
				this.start = (currentPage - 1) * pageSize;
				this.offset = pageSize;
			}
			else if (dsname.equals(Constant.DATASOURCE_ORACLE)){ 
				this.start = (currentPage - 1) * pageSize + 1;
				this.offset = currentPage * pageSize;				
			}
			else if (dsname.equals(Constant.DATASOURCE_SQLSERVER)){ 
				this.start = (currentPage - 1) * pageSize;
				this.offset = currentPage * pageSize + 1;
			}
			else if (dsname.equals(Constant.DATASOURCE_DB2)){ 
				//以后待补
			}
			else if (dsname.equals(Constant.DATASOURCE_SYBASE)){ 
				//以后待补
			}
			else if (dsname.equals(Constant.DATASOURCE_INFORMIX)){ 
				//以后待补
			}	
			else if (dsname.equals(Constant.DATASOURCE_POSTGRES)){ 
				//以后待补
			}			
		}
		this.pageSize = pageSize;
		this.currentPage = currentPage;
	}

	public int getRecordCount() {
		return recordCount;
	}

	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}
	
	
}
